﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;
public partial class Bidder_TraNoPS : System.Web.UI.Page
{
     string  _BuyPlanGoodsId = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumCompany);
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumHospitale);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {
            if (!IsPostBack)
            {
                _BuyPlanGoodsId = SysFun.IsSQL(Request.QueryString["BId"].ToString());
                if (Request.QueryString["id"] == null || Request.QueryString["id"] == "")
                {
                    Button1.Visible = false;
                }    
                ViewState["bugid"] = _BuyPlanGoodsId;
                System.Data.IDataReader drn;
                Db dbn = new Db();
                string strNp = "select NoPsResoin from BuyPlanGoods where BuyPlanGoodsId=" + _BuyPlanGoodsId.Split(',')[0];
                drn = dbn.DataReader(strNp);
                if (drn.Read())
                {
                    TextBox1.Text = SysFun.ToTrim(drn["NoPsResoin"].ToString());
                }
                drn.Dispose();
                drn.Close();
                dbn.Close();
                HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
                if (_Account.Type == "3") //医院
                {
                    Button1.Visible = false;
                }

            }
        }
    }
   

    protected void Button1_Click(object sender, EventArgs e)//不配送
    {
        HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
        if (_Account != null)
        {
            if (SysFun.ToTrim(TextBox1.Text) == "")
            {
                Response.Write("<script>alert('原因必填！')</script>");
                return;
            }
            //DealStatus 0 默认 1为企业确认送货 2 为 医院入库 3 为 退货 4 为 企业无法配送 5 已确认到期未送货 
            Db db = new Db();
            string strSql = "update BuyPlanGoods set NoPsResoin='" + SysFun.ToTrim(TextBox1.Text) + "', DealStatus=4 where BuyPlanGoodsId in (" + (string)ViewState["bugid"] + ")";
            db.Command(strSql);
            db.Close();
            HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "更新", "BuyPlanGoods", strSql, "../Bidder/TraNoPS.aspx");
            Response.Write("<script>window.opener.location.reload();window.close();</script>");
        }
        else
        {
            Response.Write("<script language=JavaScript>alert('您无权修改信息！！！');</script>");
        }
    }

}
